package GradeCalculation;

import java.util.List;

/**
 * @Author maojiangyue
 * @Date 2025/10/18
 * @Description 学生成绩计算-根据科目加权计算
 */
public class StudentGrades implements GradeCount{
    private double CHINESE_WEIGHT;
    private double MATH_WEIGHT;
    private double ENGLISH_WEIGHT;
    private double COMPUTER_WEIGHT;
    private double PE_WEIGHT;

    public StudentGrades(double CHINESE_WEIGHT, double MATH_WEIGHT,
                         double ENGLISH_WEIGHT, double COMPUTER_WEIGHT, double PE_WEIGHT) {
        this.CHINESE_WEIGHT = CHINESE_WEIGHT;
        this.MATH_WEIGHT = MATH_WEIGHT;
        this.ENGLISH_WEIGHT = ENGLISH_WEIGHT;
        this.COMPUTER_WEIGHT = COMPUTER_WEIGHT;
        this.PE_WEIGHT = PE_WEIGHT;
    }

    @Override
    public double averageScore(List<Double> score) {
        if (score==null || score.isEmpty()){
            return 0;
        }
        return score.get(0)*CHINESE_WEIGHT
                +score.get(1)*MATH_WEIGHT
                +score.get(2)*ENGLISH_WEIGHT
                +score.get(3)*COMPUTER_WEIGHT
                +score.get(4)*PE_WEIGHT;
    }

    @Override
    public String getName() {
        return "学生成绩";
    }
}
